#ifndef FRMMAIN_H
#define FRMMAIN_H

#include <QtGui/QMainWindow>
#include <QtCore/QtCore>
#include "ui_frmmain.h"
#include "device.h"
//Yep! Path including is a bad idea.
#include "qextserialport.h"
#include "atjenie_parser.h"
#include "daa_ps.h"

typedef struct
{
    uint8_t   u8ChMask;
    uint8_t   u8CmdCode;
} tsPowerServiceCmd_;

class frmMain : public QMainWindow
{
	Q_OBJECT

public:
	//! Constructor
	frmMain(QWidget *parent = 0, Qt::WFlags flags = 0);
	~frmMain();

private:
	Ui::frmMainClass ui;
	QTimer timer;
	// General electricity parameters
	//! Voltage
	float Voltage;
	//! Frequency
	float Frequency;
	//! Total power
	float Power;
	//! Icon size
	int IconSize;
	//! Interval
	int Interval;
	//! Font
	QFont fnt;
	//! Device list
	QList<TDevice> devices;
	//! Selected device
	int SelectedDevice;
	//! Port
	QextSerialPort *port;
	//! Info string
	QString stInfo;

	ATJenie_Parser *Parser;

	//! Address of smart meter
	quint64 MeterAddress;
	//! Address of smart socket
	quint64 SocketAddress;

	// Private functions

	//! Repainting graphics view
	void pic_Paint();
	//! Resizing graphics view
	void pic_Resize();
	//! Show context menu
	void pic_ShowMenu(const QPoint& pos);

	//! Update general info
	void UpdateInfo();

	void ShowDeviceInfo(int dev_id);
	//! Load list of devices from settings file
	void LoadDeviceList();
	void ConnectDevice(int dev_id);
	void DisconnectDevice(int dev_id);

	void ProcessPowerConsumption(float NewPower);

	//! Identify connected devices using the new power consumption value
	void IdentifyDevices();
private slots:
        //void readyRead();
	//! New node connected
        //void NewNode(quint64 Address,quint32 Service);
	//! New data from node
        void NetworkConnected(AtJenie_NTU NTU);
<<<<<<< .mine

		//! Event from timer
		void timerEvent();
=======
        void RegisterServiceResponse();
        void ServiceRequestResponse(uint64_t u64AddressRomote, uint32_t u32ServiceMask);

>>>>>>> .r35
protected:
	virtual bool eventFilter(QObject *obj, QEvent *ev);
        uint64_t u64MAC;
};

#endif // FRMMAIN_H
